package com.timoon.sample.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.timoon.sample.dao.ProductSortDAO;
import com.timoon.sample.dao.model.ProductSort;
import com.timoon.sample.dao.model.ProductSortExample;
import com.timoon.webcomponent.utility.product.sort.sortnav1.InsideNavsService;

/**
 *<p></p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013.4.1</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */

@Service(value="com.timoon.webcomponent.utility.navs.service.NavsService")
public class NavsService implements InsideNavsService {

	@Resource
	private ProductSortDAO productSortDAOImpl;
	
	@SuppressWarnings("unchecked")
	@Override
	public List<ProductSort> getParentProductSort() {
		// TODO Auto-generated method stub
		return this.productSortDAOImpl.selectByExample(new ProductSortExample(){{
			this.createCriteria().andParentIdEqualTo(0).andStatusNotEqualTo(0);
		}});
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ProductSort> getChildProductSortByParentId(final Integer id) {
		// TODO Auto-generated method stub
		return this.productSortDAOImpl.selectByExample(new ProductSortExample(){{
			this.createCriteria().andStatusNotEqualTo(0).andParentIdEqualTo(id);
		}});
	}

	public ProductSortDAO getProductSortDAOImpl() {
		return productSortDAOImpl;
	}

	public void setProductSortDAOImpl(ProductSortDAO productSortDAOImpl) {
		this.productSortDAOImpl = productSortDAOImpl;
	}

}
